package test

import (
	"bytes"
	"card/pkg/database"
	"github.com/agiledragon/gomonkey/v2"
	"github.com/gin-gonic/gin"
	"gorm.io/gorm"
	"net/http"
	"net/http/httptest"
)

func Get() {

}
func Post(path string, handler func(c *gin.Context), request []byte) {
	gin.SetMode(gin.TestMode)
	w := httptest.NewRecorder()
	_, r := gin.CreateTestContext(w)
	r.POST(path, handler)
	url := "http://127.0.0.1:9502" + path
	r.ServeHTTP(w, httptest.NewRequest(http.MethodPost, url, bytes.NewReader(request)))

}

func MockDb(patcthes *gomonkey.Patches) {
	db := &gorm.DB{}
	patcthes.ApplyFuncReturn(database.GetDao, db)
	patcthes.ApplyMethodFunc(db, "Begin", db)

}
func MockRedis() {

}
